Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove SBV from the SMT backend #93

Merged
merged 63 commits into from
Apr 29, 2021
Merged

Remove SBV from the SMT backend #93

merged 63 commits into from
Apr 29, 2021

Conversation

d-xo
Copy link
Collaborator

@d-xo d-xo commented Apr 27, 2021

This PR rewrites the SMT backend to remove the usage of the sbv library. We now generate smt2 directly in SMT.hs without going through an additional abstraction layer.

The primary motivation for this change was to allow the encoding of mappings in act as arrays in SMT. Doing this with sbv was surprisingly hard (sbv uses tuples for array indicies, act uses a nonempty list), and would have required either extensive modifications to the structure of the AST, significant additional boilerplate, or template haskell.

There are some additional benefits regarding auditability and debugging: the new SMT backend is less than 500 lines (compared to many thousand for sbv), and the resulting queries are significantly more readable.

The big disadvantage here is that we have to keep the sbv based code around for interfacing with hevm (which still relies on sbv for now), this is unfortunate, but seems to be a price worth paying given the alternatives.

CLI output is currently very rough, and counterexamples are currently not generated, I intend to work on this next.

This PR closes the following issues: #62, #72, #91, #58

d-xo and others added 30 commits March 9, 2021 18:12
src/HEVM.hs Outdated Show resolved Hide resolved
@kjekac
Copy link
Collaborator

kjekac commented Apr 28, 2021

I took it upon myself to just go ahead and commit all the redundant parentheses I encountered since that seemed like a no-brainer 🙃 still one other suggestion open though and may add more. Looks very good in general though, I'm really just nitpicking.

src/HEVM.hs Outdated Show resolved Hide resolved
src/Main.hs Outdated Show resolved Hide resolved
src/SMT.hs Outdated Show resolved Hide resolved
src/SMT.hs Outdated Show resolved Hide resolved
src/SMT.hs Outdated Show resolved Hide resolved
src/SMT.hs Outdated Show resolved Hide resolved
src/SMT.hs Outdated Show resolved Hide resolved
src/SMT.hs Outdated Show resolved Hide resolved
src/SMT.hs Outdated Show resolved Hide resolved
src/SMT.hs Outdated Show resolved Hide resolved
src/HEVM.hs Outdated Show resolved Hide resolved
src/SMT.hs Outdated Show resolved Hide resolved
@MrChico
Copy link
Member

MrChico commented Apr 28, 2021

this is really nice! Can we add a test for #58 now that it works?

@d-xo
Copy link
Collaborator Author

d-xo commented Apr 28, 2021

Can we add a test for #58 now that it works?

done.

@kjekac
Copy link
Collaborator

kjekac commented Apr 28, 2021

I already approved before the new test so I can't do it again but looks great :)

@d-xo d-xo merged commit 3944f4f into master Apr 29, 2021
@d-xo d-xo deleted the no-sbv branch April 29, 2021 10:41

invariants

b[a] == 1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants